package com.hjm.project.agentInfo.total.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.agentInfo.total.domain.AgentTotal;
import com.hjm.project.agentInfo.total.service.IAgentTotalService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 服务商信息统计Controller
 * 
 * @author LOVE
 * @date 2020-12-07
 */
@Controller
@RequestMapping("/agentInfo/total")
public class AgentTotalController extends BaseController
{
    private String prefix = "agentInfo/total";

    @Autowired
    private IAgentTotalService agentTotalService;

    @RequiresPermissions("agentInfo:total:view")
    @GetMapping()
    public String total()
    {
        return prefix + "/total";
    }

    /**
     * 查询服务商信息统计列表
     */
    @RequiresPermissions("agentInfo:total:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgentTotal agentTotal)
    {
        startPage();
        List<AgentTotal> list = agentTotalService.selectAgentTotalList(agentTotal);
        return getDataTable(list);
    }

    /**
     * 导出服务商信息统计列表
     */
    @RequiresPermissions("agentInfo:total:export")
    @Log(title = "服务商信息统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgentTotal agentTotal)
    {
        List<AgentTotal> list = agentTotalService.selectAgentTotalList(agentTotal);
        ExcelUtil<AgentTotal> util = new ExcelUtil<AgentTotal>(AgentTotal.class);
        return util.exportExcel(list, "total");
    }

    /**
     * 新增服务商信息统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存服务商信息统计
     */
    @RequiresPermissions("agentInfo:total:add")
    @Log(title = "服务商信息统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgentTotal agentTotal)
    {
        return toAjax(agentTotalService.insertAgentTotal(agentTotal));
    }

    /**
     * 修改服务商信息统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AgentTotal agentTotal = agentTotalService.selectAgentTotalById(id);
        mmap.put("agentTotal", agentTotal);
        return prefix + "/edit";
    }

    /**
     * 修改保存服务商信息统计
     */
    @RequiresPermissions("agentInfo:total:edit")
    @Log(title = "服务商信息统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgentTotal agentTotal)
    {
        return toAjax(agentTotalService.updateAgentTotal(agentTotal));
    }

    /**
     * 删除服务商信息统计
     */
    @RequiresPermissions("agentInfo:total:remove")
    @Log(title = "服务商信息统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(agentTotalService.deleteAgentTotalByIds(ids));
    }
}
